package com.shenmazong.servereduschool.controller;

import com.github.pagehelper.PageInfo;
import com.shenmazong.servereduschool.mapper.TbStageMapper;
import com.shenmazong.servereduschool.pojo.TbStage;
import com.shenmazong.servereduschool.service.TbStageService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 阶段
 * kxt
 */
@RequestMapping("/stage")
@RestController
public class TbStageController {
    @Autowired
    TbStageService tbStageService;

    /**
     * 阶段列表
     * @return
     */
    @PostMapping("/stageList")
    public ResultResponse findStageList(@RequestBody ListParamVo listParamVo){
        Integer current = listParamVo.getCurrent();
        Integer size = listParamVo.getSize();
        Object tbStage = listParamVo.getParamMap().get("tbStage");
        PageInfo pageInfo=tbStageService.findStageList(current,size,tbStage);
        return ResultResponse.SUCCESS(pageInfo);
    }

    /**
     * 阶段新增
     * @param tbStage
     * @return
     */
    @PostMapping("/saveStage")
    public ResultResponse save(@RequestBody TbStage tbStage){
        return tbStageService.add(tbStage);
    }

    /**
     * 阶段回显
     * @param tbStage
     * @return
     */
    @PostMapping("/queryByStageId")
    public ResultResponse queryByStageId(@RequestBody TbStage tbStage){
        return tbStageService.queryByStageId(tbStage);
    }

    /**
     * 阶段修改
     * @param tbStage
     * @return
     */
    @PostMapping("/updateStage")
    public ResultResponse updateStage(@RequestBody TbStage tbStage){
        return tbStageService.updateStage(tbStage);
    }

    /**
     * 阶段删除
     * @param tbStage
     * @return
     */
    @PostMapping("/delByStageId")
    public ResultResponse delByStageId(@RequestBody TbStage tbStage){
        return tbStageService.delByStageId(tbStage);
    }

    /**
     * 阶段es
     * @param pageNum
     * @param pageSize
     * @param tbStage
     * @return
     */
    @PostMapping("/findStage/{pageNum}/{pageSize}")
    public ResultResponse findStage(@PathVariable("pageNum") Integer pageNum,
                                    @PathVariable("pageSize") Integer pageSize,
                                    @RequestBody TbStage tbStage){
        return tbStageService.findStage(pageNum,pageSize,tbStage);
    }

    @PostMapping("/delAll")
    public ResultResponse delAll(@RequestBody List<TbStage> ids){
        return tbStageService.delAll(ids);
    }

    /**
     * 阶段下拉
     * @return
     */
    @PostMapping("/findTbStageList")
    public ResultResponse findTbStageList(){
        return tbStageService.findTbStageList();
    }

}
